﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Puzzler.Common;

namespace Puzzler.Plugin.Interface
{
    public abstract class PuzzleIOUpgrateHandler<TModel> : IPuzzleIOUpgrateHandler, IModelable<TModel> where TModel : PuzzleModel
    {
        public TModel Model { get; private set; }

        protected PuzzleIOUpgrateHandler(TModel model)
        {
            Model = model;
        }

        public abstract bool UpgrateXml(XElement element, int foundVersion, int currentVersion);
        public abstract bool UpgrateBinary(StreamReader reader, int foundVersion, int currentVersion);

        #region Plugin Action

        public virtual void OnInitialized()
        {
        }

        public virtual void OnDone()
        {
        }

        public virtual void OnActivated()
        {
        }

        public virtual void OnDeactivated()
        {
        }

        #endregion
    }
}
